package com.uenpay.im.invokeitems.chat;

import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author SL
 * @copyRight http://www.qiyunxin.com
 * @date 2016-5-24 下午2:30:00
 * @version 1.0
 * @function 撤销消息
 * 
 */
public class RevokeMsgInvokeItem extends BaseHttpInvokeItem {

	public class RevokeMsgInvokeItemResult extends HttpInvokeResult {

	}

	public RevokeMsgInvokeItemResult getOutPut() {
		return (RevokeMsgInvokeItemResult) GetResultObject();
	}

	/**
	 * 撤销消息
	 * 
	 * @param chat_id
	 * @param cust_id
	 * @param msg_no
	 */
	public RevokeMsgInvokeItem(String chat_id, String cust_id, String msg_no) {
		String url = APIConfiguration.getBaseUrl()
				+ "Chat/Chat/revokeMsg?chatid=" + chat_id + "&custid="
				+ cust_id + "&msgno=" + msg_no + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		RevokeMsgInvokeItemResult result = new RevokeMsgInvokeItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");
		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}

		return result;
	}
}
